﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using VideoClassLibrary.BusinessLogicLayer;
public partial class TrainClassManagement_ViewTrainingClassList : AdminUserBase
{
    public string SchoolName = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        TeacherModule ta = new TeacherModule();
        SchoolName = ta.GetSchNameByID(this.SchoolID); 
        if (!IsPostBack)
        {
            BindPageData();
        }

    }
    public void BindPageData()
    {
        TrainClassModule tm = new TrainClassModule();
        DataSet ds = new DataSet();
        string where = " and VTC_name like '%" + TxtCheckTClass.Text.Trim() + "%'";
        ds = tm.GetTrainclassListByWhere(this.SchoolID, where);
        Repeater1.DataSource = getPage(ds);
        Repeater1.DataBind();
    }
    protected void BtnSearch_Click(object sender, EventArgs e)
    {
        BindPageData();

    }
    public PagedDataSource getPage(DataSet ds)
    {
        this.pager.RecordCount = ds.Tables[0].Rows.Count;
        PagedDataSource pds = new PagedDataSource();
        pds.DataSource = ds.Tables[0].DefaultView;
        pds.AllowPaging = true;
        pds.CurrentPageIndex = pager.CurrentPageIndex - 1;
        pds.PageSize = pager.PageSize;
        return pds;
    }
    /// <summary>
    /// 分页事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void pager_PageChanged(object sender, EventArgs e)
    {
        BindPageData();
    }
    /// <summary>
    /// 根据选择删除数据
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnDelete_Command(object sender, CommandEventArgs e)
    {
        int id = int.Parse(e.CommandArgument.ToString());
        TrainClassModule train = new TrainClassModule();
        train.TrainDelete(id);
        Response.Redirect("ViewTrainingClassList.aspx");
    }
    /// <summary>
    /// 修改培训班信息
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    public void btnUpdate_Click(object sender, CommandEventArgs e)
    {
        Response.Redirect("UpdateTrainClass.aspx?TCID=" + e.CommandArgument.ToString());
    }
    /// <summary>
    /// 查看培训班的课程表列表
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    public void  btnToCourse_Click(object sender, CommandEventArgs e)
    {
        Response.Redirect("TCCourseList.aspx?TCID=" + e.CommandArgument.ToString());
    }

    /// <summary>
    /// 查看培训班的课程列表
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    public void btnClassCourse_Click(object sender, CommandEventArgs e)
    {
        Response.Redirect("CourseCalendar.aspx?ID=" + e.CommandArgument.ToString());
    }
    public void btnFormatCourse_Click(object sender, CommandEventArgs e)
    {
        Response.Redirect("ClassCourseCalendar.aspx?ID=" + e.CommandArgument.ToString());
    }

    
    
    /// <summary>
    /// 新建培训班
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void BtnCreateTrainingClass_Click(object sender, EventArgs e)
    {
        Response.Redirect("AddTrainClass.aspx");
    }
    /// <summary>
    /// 快速录入学员信息
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    public void btnFastAddUser_Click(object sender, CommandEventArgs e)
    {
        string argValue = e.CommandArgument.ToString();
        string[] argValueList = argValue.Split('|');

        Response.Redirect("AddUserList.aspx?TClassId=" + argValueList[0] + "&TClassName=" + argValueList[1]);
    }
    /// <summary>
    /// 批量录入课程
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    public void btnCreateCourse_Click(object sender, CommandEventArgs e)
    {
        string argValue = e.CommandArgument.ToString();
        string[] argValueList = argValue.Split('|');

        Response.Redirect("QuantityAddCourseInfo.aspx?TClassId=" + argValueList[0] + "&TClassName=" + argValueList[1]+"&T=L");
    }

}

